import { createApp } from 'vue';
import pinia from '/@/stores/index';
import App from './App.vue';
import router from './router';
import { directive } from '/@/directive';
import { i18n } from '/@/i18n';
import other from '/@/utils/other';

import ElementPlus from 'element-plus';
import '/@/theme/tailwind.css';
import 'element-plus/dist/index.css';
import '/@/theme/index.scss';
import '/@/assets/styles/common.scss';

// @ts-ignore 引入VForm3库
import VForm3 from 'form-designer-plus'; //
import 'form-designer-plus/dist/designer.style.css'; //引入VForm3样式
// 部门树组件
import vue3TreeOrg from 'vue3-tree-org';
import 'vue3-tree-org/lib/vue3-tree-org.css';

// 日历组件
import { setupCalendar } from 'v-calendar';

import { DelWrap, DictTag, Editor, ElementIcons, Pagination, RightToolbar, Tip, UploadExcel, UploadFile, UploadImg } from '/@/components/index';
import { dateStr, dateTimeStr, parseDate, parseTime, timeStr } from '/@/utils/formatTime';


// @ts-ignore 布局工具
import { Pane, Splitpanes } from 'splitpanes';
import 'splitpanes/dist/splitpanes.css';

import { TUIChatKit, TUIComponents } from './TUIKit/index';

// 全局方法
import {
	currencySymbol,
	amountFormat,
	stateFormat,
	langFormat,
	trim,
	distanceFormat,
	joinFormat,
	dateformat,
	dateRangeFormat,
	nameMobileFormat,
	openUrl,
	getFileUri
} from "./utils/util";

const app = createApp(App);

// 日期格式
export const dateTimePattern = 'YYYY-MM-DD HH:mm:ss';
// oss文件访问路径
// export const ossFileUrl = 'https://file.foxtool.jijianjide.com/pandaf/';
export const ossFileUrl = 'https://oss.king-of-panda.com/';
// 语言
export const languages = [
	{ label: '中文', value: 'zh-cn', iconfont: 'icon-fuhao-zhongwen' },
	{ label: 'English', value: 'en', iconfont: 'icon-fuhao-yingwen' },
	// {label: 'Français', value: 'fr', iconfont: 'icon-fuhao-yingwen'},
];



// 导入通用自定义组件
app.component('DictTag', DictTag);
app.component('Pagination', Pagination);
app.component('RightToolbar', RightToolbar);
app.component('uploadExcel', UploadExcel);
app.component('UploadFile', UploadFile);
app.component('UploadImg', UploadImg);
app.component('Editor', Editor);
app.component('Tip', Tip);
app.component('DelWrap', DelWrap);
// 导入布局插件
app.component('Splitpanes', Splitpanes);
app.component('Pane', Pane);
// 全局方法挂载
app.config.globalProperties.parseTime = parseTime;
app.config.globalProperties.parseDate = parseDate;
app.config.globalProperties.dateTimeStr = dateTimeStr;
app.config.globalProperties.dateStr = dateStr;
app.config.globalProperties.timeStr = timeStr;
app.config.globalProperties.baseURL = import.meta.env.VITE_API_URL;
// oss文件访问路径
app.config.globalProperties.$ossFile = '/admin/sys-file/oss/file?fileName=';
// 获取文件资源地址
app.config.globalProperties.$getFileUri = getFileUri;
// 货币符号
app.config.globalProperties.$currencySymbol = currencySymbol;
// 日期格式
app.config.globalProperties.$dateTimePattern = dateTimePattern;
// 语言
app.config.globalProperties.$languages = languages;

app.config.globalProperties.$amountFormat = amountFormat
app.config.globalProperties.$stateFormat = stateFormat
app.config.globalProperties.$langFormat = langFormat
app.config.globalProperties.$trim = trim
app.config.globalProperties.$distanceFormat = distanceFormat
app.config.globalProperties.$joinFormat = joinFormat

app.config.globalProperties.$dateformat = dateformat
app.config.globalProperties.$dateRangeFormat = dateRangeFormat

app.config.globalProperties.$nameMobileFormat = nameMobileFormat

app.config.globalProperties.$openUrl = openUrl


// 聊天组件初始化
TUIChatKit.components(TUIComponents, app);
TUIChatKit.init();


directive(app);
other.elSvg(app);
app
	.use(pinia) // pinia 存储
	.use(router) // 路由
	.use(ElementPlus) // ElementPlus 全局引入
	.use(ElementIcons) // elementIcons 图标全局引入
	.use(VForm3) // 表单设计
	.use(vue3TreeOrg) // 组织架构组件
	.use(i18n) // 国际化
	.use(setupCalendar, {}) // 日历组件
	.mount('#app');

